package com.mindao.app.weixin.model;
 

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mindao.app.common.spring.model.BaseModel;

/**
/* 版权所有： 广州敏道科技有限公司
/*
/* 功能描述：
/*
/* 创 建 人：李国才
/* 创建时间：2016年7月17日 下午4:00:22 	
 **/
@Entity
@Table(name = "weixin_mp_button")
public class WxmpButton extends BaseModel{
	public final static int DISABLED_TRUE=1;
	public final static int DISABLED_FALSE=0;
	
	public final static String TYPE_VIEW="view";
	public final static String TYPE_CLICK="click";
	public final static String TYPE_MEDIA_ID="media_id";
	//public final static String TYPE_SCANCODE_PUSH="scancode_push";
	public final static String TYPE_LOCATION_SEELCT="location_select";
	/** 菜单的响应动作类型 **/
 
	private String type;
	/** 菜单标题，不超过16个字节，子菜单不超过40个字节 **/
	private String name;
	
	/** 菜单KEY值，用于消息接口推送，不超过128字节 **/
	
	private String key;
	/** 网页链接，用户点击菜单可打开链接，不超过1024字节 **/
	private String url;
	/** 调用新增永久素材接口返回的合法media_id **/
	private String media_id;
	
	private Long sortNob;
	
	private Integer disabled;
	
	//父按钮
	private WxmpButton parentModel;

	 
	
	

	
	@ManyToOne 
	@JoinColumn(name = "parent_id", nullable = true)
	public WxmpButton getParentModel() {
		return parentModel;
	}
	public void setParentModel(WxmpButton parentModel) {
		this.parentModel = parentModel;
	}
	
	 
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	 
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getMedia_id() {
		return media_id;
	}
	public void setMedia_id(String media_id) {
		this.media_id = media_id;
	}
	
	
	public Long getSortNob() {
		return sortNob;
	}
	public void setSortNob(Long sortNob) {
		this.sortNob = sortNob;
	}
	@Transient
	public String getTypeText(){
		if (TYPE_VIEW.equals(type)){
			return "外部链接(view)";
		}else if (TYPE_CLICK.equals(type)){
			return "点击事件(click)";
		}else if (TYPE_MEDIA_ID.equals(type)){
			return "发送图文(media_id)";
		}else if (TYPE_LOCATION_SEELCT.equals(type)){	
			return "选择位置(location_select)";
		}
		return "";
	}
	public Integer getDisabled() {
		return disabled;
	}
	public void setDisabled(Integer disabled) {
		this.disabled = disabled;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name="myKey")
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public WxmpButton(String type, String name, String key, String url,
			String media_id, Long sortNob, WxmpButton parentModel) {
		super();
		this.type = type;
		this.name = name;
		this.key = key;
		this.url = url;
		this.media_id = media_id;
		this.sortNob = sortNob;
		this.parentModel = parentModel;
	}
	
	public WxmpButton(){
		super(); 
	}
	public WxmpButton( String name,Long sortNob){
		 this.name=name;
	}
	
}
